#pragma once
#include "VC_Drawable.h"
#include "C_Texture.h"
#include "VC_Object.h"

class C_Sprite : public VC_Drawable
{
private:
	C_Texture				*m_texture; //texture
	sf::Sprite				*m_sprite;	//sprite
	std::string				 m_path;	//path
public:
	C_Sprite();
	~C_Sprite();

	void loadFromFile(std::string filename);

	///////////////////////////////////////////////////////////////////////////////////////
	///////////////	VIRTUAL DRAWABLE
	virtual void render();
	virtual void update();

	///////////////////////////////////////////////////////////////////////////////////////
	///////////////	WIDTH HEIGHT
	inline float width()	{ return m_sprite->getTexture()->getSize().x; }
	inline float height()	{ return m_sprite->getTexture()->getSize().y; }

	///////////////////////////////////////////////////////////////////////////////////////
	///////////////	SIZE POSITION ANGLE
	void setSize	(float w, float h) { m_sprite->setScale(sf::Vector2f(w / width(), h/height()));	}
	void setPos		(float x, float y) { m_sprite->setPosition(sf::Vector2f(x, y));					}
	void setAngle	(float a)		   { m_sprite->setRotation(a);									}
	void setColor	(sf::Uint8 r, 
					 sf::Uint8 g, 
					 sf::Uint8 b, 
					 sf::Uint8 a)	   { m_sprite->setColor(sf::Color(r, g, b, a)); }
	void setRect(int x, int y, int w, int h) { m_sprite->setTextureRect(sf::IntRect(x, y, w, h)); }

	sf::Vector2f pos() { return m_sprite->getPosition(); }
	sf::Color	 color() { return m_sprite->getColor(); }
	sf::Uint8	 red() { return m_sprite->getColor().r; }
	sf::Uint8	 green() { return m_sprite->getColor().g; }
	sf::Uint8	 blue() { return m_sprite->getColor().b; }
	sf::Uint8	 alpha() { return m_sprite->getColor().a; }

	friend class C_Texture;
private:
	void setTexture(sf::Texture *t);
};

